/**
 * 封装新闻相关API接口
 */
import request from '../utils/request'

/**
 * 获取频道新闻列表
 * @param {*} channel_id 频道
 * @param {*} timestamp（page_no） 分页参数
 * @param {*} with_top （0 ｜1）是否返回置顶新闻
 */
// eslint-disable-next-line camelcase
export function aritcles (channel_id, timestamp, with_top = 1) {
  return request.get('articles', {
    params: { channel_id, timestamp, with_top }
  })
}

export function dislikeArticle (target) {
  return request.post('article/dislikes', {
    target
  })
}

/**
 * 联想补全接口
 * @param {*} q 关键词前缀
 */
export function suggest (q) {
  return request.get('suggestion', {
    params: { q }
  })
}

// 搜索文章
// eslint-disable-next-line camelcase
export function searchArticles ({ page = 1, per_page = 20, q }) {
  return request.get('search', {
    params: {
      page,
      per_page,
      q
    }
  })
}
